#define _CRT_SECURE_NO_WARNINGS 1
#include "List.h"
LT* createnewnode(LTtypedate x) {
	LT* newnode = (LT*)malloc(sizeof(LT));
	if (newnode == NULL)
	{
		perror("malloc:");
		exit(-1);
	}
	newnode->val = x;
	newnode->next = NULL;
	return newnode;
}
void ListPushback(LT** phead, LTtypedate x) {
	assert(phead);
	LT* newnode = createnewnode(x);
	if (*phead == NULL)
	{
		*phead = newnode;
	}
	else
	{
		LT* cur = *phead;
		while (cur->next)
		{
			cur = cur->next;
		}
		cur->next = newnode;
	}
}
void ListPopBack(LT** phead) {
	assert(phead);
	assert(*phead);
	if ((*phead)->next == NULL)
	{
		free(*phead);
		*phead = NULL;
	}
	else
	{
		LT* cur = *phead;
		LT* lost = NULL;
		while (cur->next)
		{
			lost = cur;
			cur = cur->next;
		}
		free(cur);
		lost->next = NULL;
	}
}
void ListPushFront(LT** phead , LTtypedate x) {
	assert(phead);
	LT* newnode = createnewnode(x);
	newnode->next = *phead;
	*phead = newnode;
}